package cn.edu.cuc.yjsy.admin.connection;

import java.io.IOException;
import java.sql.DriverManager;
import java.sql.SQLException;

import cn.edu.cuc.yjsy.admin.util.Op;
import cn.edu.cuc.yjsy.database.Database;


public class TargetConnection extends AbstractConnection {
	
	private static class TargetConnectionInstance{
		static final TargetConnection connection = new TargetConnection();
	}
	
	public static TargetConnection getInstance(){
		return TargetConnectionInstance.connection;
	}
	
	private TargetConnection(){
		super("targetdb.xml");
	}
	
	public Database getDatabase(){
		return db;
	}

	public void connection() throws SQLException {
		conn = DriverManager.getConnection(Op.toLocaleString(db.getUrl()));
	}
	
	public void saveConfiguration() throws IOException{
		dbManager.save();
		fetchTableName();
	}
}
